//C++的线程库本质是对pthread的封装, 因为去掉-lpthread选项之后报链接错误

#include <iostream>
#include <thread>
#include <unistd.h>
using namespace std;

void myrun() 
{
    while(true)
    {
        cout << "I am a thread" << endl;
        sleep(1);
    }
}
 
int main() { 
    thread t(myrun);
    t.join();
    return 0;
}